package com.reggie.lotterysystem.dao.mapper;

import com.reggie.lotterysystem.dao.dataobject.ActivityDO;
import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {

    @Insert("insert into activity(activity_name,description,status) values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insert(ActivityDO activityDO);

    @Select("select count(1) from activity")
    int count();

    @Select("select * from activity order by id desc limit #{offset}, #{pageSize}")
    List<ActivityDO> selectActivityList(Integer offset, Integer pageSize);

    @Select("select * from activity where id = #{activityId}")
    ActivityDO selectById(@NotNull(message = "活动id不能为空") Long activityId);

    @Update("update activity set status = #{status} where id = #{activityId}")
    void updateStatus(Long activityId, String status);
}
